<?php
// +----------------------------------------------------------------------
// | Copyright © Sogu Technologies Co. Ltd 2018-2050 All rights reserved.
// +----------------------------------------------------------------------
// | File name: BindCardRequest.php
// +----------------------------------------------------------------------
// | Author: liuju
// +----------------------------------------------------------------------
// | Description: 描述文档功能
// +----------------------------------------------------------------------
// | Others: 其他内容的说明
// +----------------------------------------------------------------------
// | History: 修改历史记录列表，每条修改记录应包含修改日期、修改者及修改内容简述
// +----------------------------------------------------------------------
// | 1.Date: 2019-01-02 Author: liuju Modification: 创建
// +----------------------------------------------------------------------

namespace App\Http\Requests\Frontend\V10\BankCard;


use App\Rules\MobileCheck;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class BindCardRequest extends  FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'bank_name' => 'required',
            'bank_card_num' => ['bail','required','min:'.config('common.min_bank_no_size'),'max:'.config('common.max_bank_no_size')],
            'phone_num' => ['bail','required',new MobileCheck()],
            'real_name' => 'bail|required|min:2|max:100',
            'sms_code' => 'bail|required',
            'is_credit'=>['bail','nullable',Rule::in(['Y','N'])],
            'order_num'=>'bail|required|max:200',
        ];
    }

    public function messages()
    {
        return [
            'bank_name.required' => '缺少银行卡所属银行名称',
            'bank_card_num.required' => '缺少银行卡号码',
            'bank_card_num.min' => '银行卡最小长度为'.config('common.min_bank_no_size').'位',
            'bank_card_num.max' => '银行卡最小长度为'.config('common.max_bank_no_size').'位',
            'cert_num.size' => '身份证号码非有效长度',
            'phone_num.size' => '手机号长度格式非法',
            'real_name.required' => '缺少姓名信息',
            'real_name.min' => '姓名长度过短',
            'real_name.max' => '姓名长度过长',
            'sms_code.required' => '缺少验证码信息',
            'is_credit.required' => '缺少银行卡类型',
            'is_credit.in' => '银行卡类型非法',
            'order_num.required' => '缺少协议号',
            'order_num.max' => '协议号最长为200个字符',
        ];
    }

}